#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    serverManager = new ServerManager("127.0.0.1",8888,this);
    serverManager->startServer();


    connect(serverManager,&ServerManager::clientConnected,this,&Widget::onClientConnected);
}

Widget::~Widget()
{
    delete ui;
    datamanger::removeInstance();
}

void Widget::onClientConnected(QString ip, int port)
{
    QString msg = QString("[%1:%2]连接成功").arg(ip).arg(port);
    ui->listWidget->addItem(msg);
}

